package pac;

import java.util.Random;

/**
 *@time2012-12-30   
 * <think in java>Page 46:模仿抛硬币
 * */
public class Test207 {
    public static void main(String[] args){
    	Random rand = new Random();
     int x=0,y=0;
     for(int i = 0;i<20;i++){
    	 int j=rand.nextInt(2);
    	 if(j==1)
    		 x++;
    	 else
    		 y++;
     }
     System.out.println("出现正面次数x="+x);
     System.out.println("出现负面次数y="+y);
     System.out.println((float)x/y);
}
}